<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of chesscornerfilter</title>
  <meta name="keywords" content="chesscornerfilter">
  <meta name="description" content="CHESSCORNERFILTER filters Harris corners for chessboard corners.">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2005 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../../m2html.css">
  <script type="text/javascript">
    if (top.frames.length == 0) { top.location = "../../index.html"; };
  </script>
</head>
<body>
<a name="_top"></a>
<!-- # RADOCCToolbox --><!-- menu.html CornerFinder -->
<h1>chesscornerfilter
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>CHESSCORNERFILTER filters Harris corners for chessboard corners.</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>function [crnrs,nocrnrs,peaklocs]=chesscornerfilter(img,imgedge,crnrpts,debug) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre class="comment"> CHESSCORNERFILTER filters Harris corners for chessboard corners.
 
 CHESSCORNERFILTER takes as input the image, the sobel edge image and
 the Harris corner points and outputs of the corner points that passed
 the filter the number of those points and the peak directions for each 
 of the points. The peak direction is used by the grid extraction (refer 
 to Bachelor Thesis by Abdallah Kassir 2009).
   
 The details of the filter are applied in the function VALIDCORNER
 
 USAGE:
     [crnrs,nocrnrs,peaklocs]=chesscornerfilter(img,imgedge,crnrpts,debug)
 
 INPUTS:
     img: original grayscale image
 
     imgedge: Sobel edge image
 
     crnrpts: output of GETCRNRPTS
 
 OUTPUTS:
     crnrs: 2xN array of corners that passed the filter
 
     nocrnrs: number of corners found
 
     peaklocs: required by GETGRID</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="getwin.html" class="code" title="function win=getwin(img,pt,crnrpts)">getwin</a>	GETWIN chooses an appropriate window size for the chessboard corner filter</li><li><a href="sweepmatrix.html" class="code" title="function [sweepmatx,sweepmaty]=sweepmatrix(img)">sweepmatrix</a>	SWEEPMATRIX precalulates the x and y coordinates for the ray pixels used in CIRCSWEEP.</li><li><a href="validcorner.html" class="code" title="function [valid,peaklocs]=validcorner(img,imgedge,sweepmatx,sweepmaty,debug)">validcorner</a>	VALIDCORNER checks if the input corner belongs to a chessboard.</li></ul>
This function is called by:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="findcorners.html" class="code" title="function imgcout=findcorners(img,debug)">findcorners</a>	FINDCORNERS is the main function called by the calibration GUI.</li></ul>
<!-- crossreference -->



<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [crnrs,nocrnrs,peaklocs]=chesscornerfilter(img,imgedge,crnrpts,debug)</a>
0002 <span class="comment">% CHESSCORNERFILTER filters Harris corners for chessboard corners.</span>
0003 <span class="comment">%</span>
0004 <span class="comment">% CHESSCORNERFILTER takes as input the image, the sobel edge image and</span>
0005 <span class="comment">% the Harris corner points and outputs of the corner points that passed</span>
0006 <span class="comment">% the filter the number of those points and the peak directions for each</span>
0007 <span class="comment">% of the points. The peak direction is used by the grid extraction (refer</span>
0008 <span class="comment">% to Bachelor Thesis by Abdallah Kassir 2009).</span>
0009 <span class="comment">%</span>
0010 <span class="comment">% The details of the filter are applied in the function VALIDCORNER</span>
0011 <span class="comment">%</span>
0012 <span class="comment">% USAGE:</span>
0013 <span class="comment">%     [crnrs,nocrnrs,peaklocs]=chesscornerfilter(img,imgedge,crnrpts,debug)</span>
0014 <span class="comment">%</span>
0015 <span class="comment">% INPUTS:</span>
0016 <span class="comment">%     img: original grayscale image</span>
0017 <span class="comment">%</span>
0018 <span class="comment">%     imgedge: Sobel edge image</span>
0019 <span class="comment">%</span>
0020 <span class="comment">%     crnrpts: output of GETCRNRPTS</span>
0021 <span class="comment">%</span>
0022 <span class="comment">% OUTPUTS:</span>
0023 <span class="comment">%     crnrs: 2xN array of corners that passed the filter</span>
0024 <span class="comment">%</span>
0025 <span class="comment">%     nocrnrs: number of corners found</span>
0026 <span class="comment">%</span>
0027 <span class="comment">%     peaklocs: required by GETGRID</span>
0028 
0029 <span class="keyword">if</span> ~exist(<span class="string">'debug'</span>,<span class="string">'var'</span>) || isempty(debug)
0030     debug=0;
0031 <span class="keyword">end</span>
0032 
0033 <span class="comment">% comment the line to allow debugging</span>
0034 debug=0;
0035 
0036 <span class="comment">% get sweepmatrices, precalculation of these matrices allows for much</span>
0037 <span class="comment">% faster program execution</span>
0038 [sweepmatx,sweepmaty]=<a href="sweepmatrix.html" class="code" title="function [sweepmatx,sweepmaty]=sweepmatrix(img)">sweepmatrix</a>(img);
0039 
0040 <span class="comment">% set output values</span>
0041 nocrnrs=0;
0042 crnrs=[];
0043 peaklocs=[];
0044 
0045 i=0;
0046 
0047 <span class="comment">% loop over all points</span>
0048 <span class="keyword">for</span> indx=1:size(crnrpts,2)
0049     x=crnrpts(1,indx);
0050     y=crnrpts(2,indx);
0051     
0052     <span class="comment">% extract appropriate window size</span>
0053     win=<a href="getwin.html" class="code" title="function win=getwin(img,pt,crnrpts)">getwin</a>(img,[x;y],crnrpts);
0054     
0055     <span class="comment">% check window size</span>
0056     <span class="keyword">if</span> win&lt;3
0057         <span class="keyword">continue</span>;
0058     <span class="keyword">end</span>
0059     imgcrop=img(x-win:x+win,y-win:y+win);
0060     imgedgecrop=imgedge(x-win:x+win,y-win:y+win);
0061     sweepmatxcrop=sweepmatx(1:round(1.3*win),:);
0062     sweepmatycrop=sweepmaty(1:round(1.3*win),:);
0063     
0064     <span class="comment">% apply filter</span>
0065     [valid,plocs]=<a href="validcorner.html" class="code" title="function [valid,peaklocs]=validcorner(img,imgedge,sweepmatx,sweepmaty,debug)">validcorner</a>(imgcrop,imgedgecrop,sweepmatxcrop,sweepmatycrop);
0066     <span class="keyword">if</span> valid
0067         i=i+1;
0068         crnrs(1,i)=x;
0069         crnrs(2,i)=y;
0070         nocrnrs=nocrnrs+1;
0071         peaklocs(:,i)=plocs;
0072 <span class="comment">%     elseif x==129</span>
0073 <span class="comment">%         close all;</span>
0074 <span class="comment">%         imshow(imgcrop,[]);</span>
0075 <span class="comment">%         keyboard;</span>
0076     <span class="keyword">end</span>
0077 <span class="keyword">end</span>
0078 
0079 <span class="comment">% debugging</span>
0080 <span class="keyword">if</span> debug
0081     close all;
0082     figure;imshow(img);hold on;
0083     plot(crnrpts(2,:),crnrpts(1,:),<span class="string">'+'</span>);
0084     plot(crnrs(2,:),crnrs(1,:),<span class="string">'o'</span>,<span class="string">'color'</span>,<span class="string">'red'</span>);
0085     pause;
0086 <span class="keyword">end</span></pre></div>
<hr><address>Generated on Sun 04-Apr-2010 17:13:59 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" target="_parent">m2html</a></strong> &copy; 2005</address>
</body>
</html>